package com.tms.admin.controller;


import com.tms.admin.entity.TmsDriver;
import com.tms.admin.entity.TmsLogistics;
import com.tms.admin.entity.vo.DriverQueryVO;
import com.tms.admin.entity.vo.LogisticDetailVO;
import com.tms.admin.entity.vo.LogisticsQueryVO;
import com.tms.admin.service.TmsLogisticsService;
import com.tms.common.entity.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*-----------------------------------
 *   @Time: 2022/9/7 00:35
 *   @Description: 物流管理
-----------------------------------*/
@Api(value = "物流管理")
@RestController
@RequestMapping("/logistics")
@CrossOrigin
public class LogisticsController {
    @Autowired
    private TmsLogisticsService logisticsService;

    @ApiOperation(value = "根据查询条件分页/模糊查询物流信息")
    @PostMapping("page")
    public ResultVO getDriverPage(@RequestBody LogisticsQueryVO logisticsQueryVO){
        Map<String, Object> map = logisticsService.getPageByCondition(logisticsQueryVO);
        return ResultVO.ok().data("pageInfo", map);
    }

    @ApiOperation(value = "新增物流")
    @PostMapping
    public ResultVO getDriverPage(@RequestBody TmsLogistics logistics){
        logisticsService.addLogistic(logistics);
        return ResultVO.ok();
    }

    @ApiOperation(value = "物流出库")
    @DeleteMapping
    public ResultVO removeLogisticsById(@RequestBody List<Integer> logisticsIds){
        logisticsService.removeLogisticsById(logisticsIds);
        return ResultVO.ok();
    }

    @ApiOperation(value = "修改物流信息")
    @PutMapping
    public ResultVO modifyDriverById(@RequestBody TmsLogistics logistics){
        logisticsService.modifyLogisticsById(logistics);
        return ResultVO.ok();
    }

    @ApiOperation(value = "查看物流详情")
    @PostMapping("detail")
    public ResultVO getLogisticById(@RequestBody Map<String, Object> map){
        LogisticDetailVO VO = logisticsService.getLogisticById((Integer) map.get("logisticsId"));
        return ResultVO.ok().data("data",VO);
    }

}
